package com.hspedu.newData.dmsxl.数组.二分查找;
/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-12 
 * @Version: 1.0
 */

public class LC278第一个错误的版本 {

    public int firstBadVersion(int n) {

        int left = 1;
        int right = n;

        while (left <= right){
            int mid = left + (right - left) / 2;

            if (isBadVersion(mid)){
                while (isBadVersion(mid)){
                    mid--;
                }
                return mid;
            }else {
                left = mid + 1;
            }

        }

        return -1;
    }

    boolean isBadVersion(int version){

        return true;
    }
}
